
var FristPageLayer = cc.Layer.extend({
	sprite:null,
	sp_Line:null,
	sp_Star:null,
	sp_Txt:null,
	sp_closePage:null,
	sp_openPage:null,
	ctor:function () {
		//////////////////////////////
		// 1. super init first
		this._super();

		/////////////////////////////
		// 2. add a menu item with "X" image, which is clicked to quit the program
		//    you may modify it.
		// ask the window size
		var size = cc.winSize;

		// add a "close" icon to exit the progress. it's an autorelease object
		var mainScene=ccs.load(res.Frist_Json).node;
		this.addChild(mainScene);
		
		sp_Line=mainScene.getChildByName("Image_4");
		sp_Star=mainScene.getChildByName("Image_3");
		sp_Txt=mainScene.getChildByName("Image_7");
		sp_closePage=mainScene.getChildByName("FileNode_1");
		sp_openPage=mainScene.getChildByName("FileNode_2");
		sp_openPage.setVisible(false); 
//		sp_Star.setVisible(false);
//		sp_Txt.setVisible(false);
		sp_closePage.setOpacity(0);
		sp_openPage.setOpacity(0);
		sp_Line.setOpacity(0);
		sp_Star.setOpacity(0);
		sp_Txt.setOpacity(0);
		var num=1.5;
		sp_Line.runAction(
			cc.sequence(
					cc.delayTime(2.5+num),
					cc.fadeIn(2.5)
			)
		);
		sp_Star.runAction(
				cc.sequence(
						cc.delayTime(1+num),
						cc.fadeIn(2)
				)
		);
		sp_Txt.runAction(
				cc.sequence(
						cc.delayTime(6+num),
						cc.fadeIn(1)
				)
		);
		var eventListener = cc.EventListener.create({
			event: cc.EventListener.TOUCH_ONE_BY_ONE,
			swallowTouches: true,
			onTouchBegan: this.onTouchBegan});
		cc.eventManager.addListener(eventListener, this);
		return true;
	},
	onTouchBegan:function(touch, event){
//		cc.log("PageView Event Turning",sp_gouzhi1.mm_Status);
		if(gamecenter.bb_isTimeOut) return false;
		var pos=touch.getLocation();
		//cc.log("ppp=",pos.x,pos.y);
		var actionMoveDone=cc.CallFunc.create(function(node){
			mc_Hero.gotoFrameAndPause(0);
			bb_Moving=false;
		},this);
		if(pos.y<(WINSIZE.height-210)){
			if(sp_gouzhi1.getStatus()==g_Status_Normal){
				cc.audioEngine.playMusic(res.snd_shut, false);
				sp_gouzhi1.setStatus(g_Status_Shut);
			}
		}else{
			if((!bb_Moving)&&(sp_gouzhi1.getStatus()==g_Status_Normal)){
				bb_Moving=true;
				var moveTo=cc.moveTo(Math.abs(pos.x-sp_Hero.x)/300, cc.p(pos.x, sp_Hero.y));
				sp_Hero.runAction(
						cc.sequence(
								moveTo,
								actionMoveDone
						)
				);
				mc_Hero.play("move",true);
				gamecenter.hideJianTou();
			}
		}

		return false;
	}
});

var FristPageScene = cc.Scene.extend({
	onEnter:function () {
		this._super();
		var layer = new FristPageLayer();
		this.addChild(layer);
	}
});

